package com.yuyang.wifi.base;

import android.content.Context;

import com.yuyang.wifi.views.MyProgressDialog;


/**
 * Created by ttr01 on 2017/2/15.
 */

public class DialogHandlerImp implements DialogHandler {

    private Context context;
    private MyProgressDialog mDialog;

    public DialogHandlerImp(Context context) {
        this.context = context;
    }

    @Override
    public void showDialog() {
        if (mDialog == null) {
            try {
                mDialog = new MyProgressDialog(context);
                mDialog.setCanceledOnTouchOutside(false);
                mDialog.setCancelable(true);
                mDialog.show();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void dismissDialog() {
        if (mDialog != null && mDialog.isShowing()) {
            try {
                mDialog.dismiss();
                mDialog = null;
            } catch (Exception e) {
                mDialog = null;
                e.printStackTrace();
            }
        }
    }
}
